<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: August 17, 2001-->
<!--
$Id: RepTemplate.php,v 1.2 2001/11/02 15:00:10 eugenem Exp eugenem $
$Header: /export/home/eugenem/public_html/ComplianceReports/RCS/RepTemplate.php,v 1.2 2001/11/02 15:00:10 eugenem Exp eugenem $
$Log: RepTemplate.php,v $
Revision 1.2  2001/11/02 15:00:10  eugenem
Moved database connect statements to a separate file.

-->

<html>
<head>
<title>Radiological Equipment Database</title>
<meta name="author" content="Eugene Mah">
<link rev="made" href="mailto:eugenem@ix.netcom.com">
<link rev="home" href="http://home.netcom.com/~eugenem/">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="Reply-to" content="eugenem@ix.netcom.com">
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))'>
<?PHP
require('functions.inc');
require('dbc.inc');

?>
</head>

<body>
<h1>Radiological Equipment Database</h1>
<h2>Report Title</h2>
<?PHP
if (isset($ID)) {
  $orderby = "ORDER BY ";
  if(!empty($sortby)) {
    while list($name,$id) = each($sortby)) {
      $orderby .= "$id,";
    }
    $orderby = substr($order,0,-1);  // Trim the last comma
  }

  $query = "SELECT ";
  $query .= "if(ManufDate<>\"0000-00-00\",period_diff(extract(YEAR_MONTH from CURRENT_DATE),extract(YEAR_MONTH from ManufDate)),";
  $query .= "if(InstallDate<>\"0000-00-00\",period_diff(extract(YEAR_MONTH from CURRENT_DATE),extract(YEAR_MONTH from InstallDate)),\"N/A\")) as Age FROM ";
  $query .= "Modality,Manufacturer,Location,Machines WHERE (";
  while (list($name,$id) = each($modID)) {
    $query .= "ID=$id OR ";
  }
  $query = substr($query, 0, -3);  // Trim the last OR
  $query .= ") AND Active=1 AND ";
  $query .= "";
  $query .= "";
  $query .= "";

  $result = mysql_query($query)
    or die ("Query failed: $query<br>\n");
?>
<table border=1>
  <tr>
    <th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>Age</th>
  </tr>
<?PHP
  // Spit the results out into a table
  $i = 1;
  while ($row= mysql_fetch_array($result)) {
    echo "<tr>\n";
    echo "<td>" . $i . "</td>\n";
    echo "<td>" . $row[''] . "</td>\n";
    echo "<td>" . round($row['Age']/12,1) . "</td>\n";
    echo "<tr>\n";
    $i++;
  }
}
?>
</table>
<form action="Rep.php" method="POST">
<p>Select modality:
<!--
modID is specified as an array to hold multiple SELECTions for processing 
-->
<select name="ID[]" size=4 MULTIPLE>
<?PHP
/*
  Only allows for selecting one modality only.  Should add the capability
  for selecting multiple modalities.  Need to add all modalities also.
*/
$ = mysql_query("select * from  order by ");
while (list($key,$val) = mysql_fetch_array($modality)) {
  echo "<option value=\"$key\">$val</option>\n";
}
?>
</select>
(Control or Shift click to select multiple modalities)
</p>
<p>
Sort results by: 
<input type="CHECKBOX" name="sortby[]" value="Modality">Modality
<input type="CHECKBOX" name="sortby[]" value="Manufacturer">Manufacturer
<input type="CHECKBOX" name="sortby[]" value="Model">Model
<input type="CHECKBOX" name="sortby[]" value="Description">Description
<input type="CHECKBOX" name="sortby[]" value="Location">Location
</p>
<p><input type="SUBMIT" value="Search"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
</body>
</html>
